root@db 02:48: [(none)]> show variables like '%secure_file%'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | secure_file_priv | NULL | +------------------+-------+ 1 row in set (0.00 sec) root@db 02:48: [test]> select * from t1; +----+ | c1 | +----+ | 1 | +----+ 1 row in set (0.00 sec)
在值为null的时候是不允许导出数据的
1 2
root@db 02:48: [test]> select * from t1 into outfile '/tmp/t1.xls'; ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
root@db 02:49: [test]> set global secure_file_priv='/data/test'; ERROR 1238 (HY000): Variable 'secure_file_priv' is a read only variable
重启完之后,查看secure参数:
1 2 3 4 5 6 7
root@db 03:08: [(none)]> show variables like '%secure_file%'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | secure_file_priv | /tmp/ | +------------------+-------+ 1 row in set (0.02 sec)
3、导出查询数据
1 2
root@db 04:16: [test]> select * from mysql.user into outfile '/tmp/user.xls'; Query OK, 5 rows affected (0.01 sec)
如果导出的目录不是secure_file_priv指定的目录,报错:
1 2
root@db 00:17: [test]> select * from t1 into outfile '/data/t1.xls'; ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement